from typing import List, Optional
from sqlalchemy.orm import Session
from sqlalchemy import distinct
from datetime import datetime

from src.database.manager import DBManager
from src.database.models import MonitoredUser

class MonitoredUserDAO:
    def __init__(self, db_session: Session = DBManager().get_session()):
        self.db_session = db_session

    def get_categories(self) -> List[str]:
        """获取所有监控用户的唯一平台列表"""
        categories = self.db_session.query(
            distinct(MonitoredUser.category)
        ).all()
        return [cat[0] for cat in categories if cat[0] is not None]